<?php
	
	import('RelationModel');
	class DictModel extends RelationModel{
		protected $autoReadRelations = true;
		protected $_link = array(
			array(
				'mapping_type' => HAS_MANY,
				'class_name' => 'DictMap',
				'foreign_key' => 'dict_id',
				'mapping_name' => 'sub_codes',
				'mapping_order' => 'sort asc '
			)
		);
		
		/**
		 * 刷新数据字典缓存
		 * @param $list 数据字典集合
		 */
		function refreshDict(){
			
			$list = $this->findAll();
			
			for($i = 0; $i < sizeof($list); $i++ ){
				$dict_code = array();
				$dict_code['code'] = $list[$i]['dict_code'];
				$dict_code['name'] = $list[$i]['dict_name'];
				$dict_code['sub_codes'] = $list[$i]['sub_codes'];
//				print_r($dict_code) . '<br />';
				S($list[$i]['dict_code'],$dict_code);
			}
		}
	}
?>